<?php
include_once("error.php");
include_once("session.php");
include_once("mysql.php");
class identification{
	private $session;
	private $pseudonyme;
	private $mdp;
	private $id;
	function __construct(){
		$this->pseudonyme="";
		$this->mdp="";
		$this->id=0;
		$this->session=new masession();
		//AVIRER!!!
		if(isset($_GET["deco"])){
			$this->session->reset();
		}
		if(isset($_POST["pseudo"])){
			$pseudonyme=$_POST["pseudo"];
			$mdp=$_POST["mdp"];
		}else{
			$pseudonyme=$_GET["pseudo"];
			$mdp=$_GET["mdp"];
		}
		if(strlen($pseudonyme)>0){
			$this->session->reset();
			$req=new baseSql();
			$tab=$req->req2rows("SELECT id FROM membres WHERE pseudo='".$pseudonyme."' AND mdp='".$mdp."'");
			if(sizeOf($tab)==1){
				if($tab[0][0]>0){
					$this->session->add("pseudo",$pseudonyme);
					$this->session->add("mdp",$mdp);
					$this->session->add("id",$tab[0][0]);
				}
			}
		}
		if($this->session->exist("pseudo") && $this->session->exist("mdp") && $this->session->exist("id")){
			$req=new baseSql();
			$tab=$req->req2rows("SELECT COUNT(id) FROM membres WHERE pseudo='".$this->session->val("pseudo")."' AND mdp='".$this->session->val("mdp")."' AND id=".$this->session->val("id"));
			if(sizeOf($tab)==1){
				$this->pseudonyme=$this->session->val("pseudo");
				$this->mdp=$this->session->val("mdp");
				$this->id=$this->session->val("id");
			}
		}
	}
	public function isIdent(){
		return ($this->id>0);
	}
	public function pseudo(){
		return $this->pseudonyme;
	}
	public function mdp(){
		return $this->mdp;
	}
	public function id(){
		return $this->id;
	}
}
?>